/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2023-01-12
 * Time: 20:32
 */
public class Test3 {
}
//https://www.nowcoder.com/practice/4b91205483694f449f94c179883c1fef?tpId=60&&tqId=29483&rp=1&ru=/activity/oj&qru=/ta/tsing-kaoyan/question-ranking
class Node {
    char val;
    Node left;
    Node right;

    public Node(char val) {
        this.val = val;
    }
}

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static int index;

    public static Node createTree(String str) {
        Node root = null;
        if (str.charAt(index) != '#') {//由于str均为合法的前序，所以不必担心越界
            root = new Node(str.charAt(index));
            index++;
            root.left = createTree(str);
            root.right = createTree(str);
        } else {
            index++;
        }
        return root;
    }

    public static void infixOrder(Node root) {
        if (root == null) {
            return;
        }
        infixOrder(root.left);
        System.out.print(root.val + " ");
        infixOrder(root.right);
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            index = 0;//初始化静态变量，防止多组输入出错
            String str = in.nextLine();
            Node root = createTree(str);
            infixOrder(root);
        }
    }
}